﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

/**
 * 创建时间：2015/1/17 13:00:52
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace ComicIsland.Common.Converter
{
    public class IntToVisibilityConverter : IValueConverter
    {
        #region IValueConverter 成员

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            System.Windows.Visibility result = System.Windows.Visibility.Collapsed;
            try
            {
                if (value != null)
                {
                    int currentValue = -1;
                    int.TryParse(value.ToString (), out currentValue);
                    if (currentValue == 0)
                    {
                        result = System.Windows.Visibility.Visible;
                    }
                }
            }
            catch { }

            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }

        #endregion
    }
}
